package com.huixh.train.business.controller;

import com.huixh.train.business.req.SkTokenQueryReq;
import com.huixh.train.business.req.SkTokenSaveReq;
import com.huixh.train.business.resp.SkTokenQueryResp;
import com.huixh.train.business.service.SkTokenService;
import com.huixh.train.common.resp.PageResult;
import com.huixh.train.common.resp.Result;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author huixh
*/
@Validated
@RestController
@RequestMapping("/admin/skToken")
public class SkTokenController {
    @Resource
    private SkTokenService skTokenService;

    @PostMapping("/save")
    public Result<?> save(@RequestBody @Valid SkTokenSaveReq skTokenSaveReq) {
    skTokenService.save(skTokenSaveReq);
        return Result.success();
    }

    @PostMapping("/quest-list")
    public PageResult<List<SkTokenQueryResp>> query(@RequestBody @Valid SkTokenQueryReq skTokenQueryReq) {
        return skTokenService.queryList(skTokenQueryReq);
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> deleteById(@NotNull @PathVariable(name = "id") Long id) {
        skTokenService.delete(id);
        return Result.success("删除成功");
    }
}